package com.wilmar.config;
import java.util.ArrayList;
import java.util.List;
/**
 * @Title: DynamicDataSourceContextHolder.java
 * @Package:com.gethub.config
 * @Description:这里用一句话描述这个类的作用
 * @date    2018年2月8日 上午11:09:16
 * @version V1.0
 */
public class DynamicDataSourceContextHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();
    public static List<String> dataSourceIds = new ArrayList<>();

    public static void setDataSourceType(String dataSourceType) {
        contextHolder.set(dataSourceType);
    }

    public static String getDataSourceType() {
        return contextHolder.get();
    }

    public static void clearDataSourceType() {
        contextHolder.remove();
    }

    /**
     * @Description:判断指定DataSrouce当前是否存在
     * @param dataSourceId
     * @return
     */
    public static boolean containsDataSource(String dataSourceId){
        return dataSourceIds.contains(dataSourceId);
    }
}